package org.example.seckillsample.sto;

import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@ToString
@Data
public class Result implements Serializable {
    boolean success;
    String message;
    final Map<String,Object> data = new HashMap<>();

    public static Result ok(){
        Result result = new Result();
        result.success = true;
        result.message = "操作成功";
        return result;
    }
    public static Result error(){

        Result result = new Result();
        result.success = false;
        result.message = "操作失败";
        return result;
    }

    public Result data(String key,Object value){
        this.data.put(key,value);
        return this;
    }
    public Result message(String message){
        this.message = message;
        return this;
    }
}
